package com.example.system.controller;


import com.example.system.dto.LoginDTO;
import com.example.system.dto.RegDTO;
import com.example.system.entity.User;
import com.example.system.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author yanyi
 * @since 2022-01-22
 */
@RestController
@RequestMapping("/user")
@Api(value = "user表",tags = "user表接口API")
public class UserController {

    @Resource
    private IUserService userService;

    @PostMapping(value = "/login",name = "登录接口")
    public Map<String,Object> login(LoginDTO loginDTO){
        return userService.login(loginDTO);
    }

    @PostMapping("/reg")
    public Map<String,Object> reg(RegDTO regDTO){
        return userService.reg(regDTO);
    }

    @GetMapping("/listByName")
    @ApiOperation(value = "用户名分类接口")
    public Map<String,User> listByName(){
        return userService.listByName();
    }
}
